package net.sx.minemodule.mvp.activities;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.fastjson.JSON;
import com.homegoods.aroutercomment.ARouterPath;
import com.kedll.library.base.MyBaseFragmentActivity;

import net.sx.minemodule.MineApiUtils;
import net.sx.minemodule.R;
import net.sx.minemodule.adapter.MineWithDrawInfoListAdapter;
import net.sx.minemodule.databinding.MineActivityMineWithDrawInfoListBinding;
import net.sx.minemodule.mvp.bean.WithDrawInfoListBean;
import net.sx.minemodule.mvp.presenters.MineWithDrawInfoPresenter;
import net.sx.minemodule.mvp.views.MineWithDrawInfoView;

import java.util.ArrayList;
import java.util.List;

/**
 * 收益记录
 *
 * @author 11470
 */
@Route(path = ARouterPath.PATH_MINE_WITH_DRAW_INFO)
public class MineWithDrawInfoListActivity extends MyBaseFragmentActivity<MineActivityMineWithDrawInfoListBinding, MineWithDrawInfoPresenter>
        implements MineWithDrawInfoView {

    private MineWithDrawInfoListAdapter listAdapter;

    @Override
    protected int getLayout() {
        return R.layout.mine_activity_mine_with_draw_info_list;
    }

    @Override
    protected void initToolBar(Bundle savedInstanceState) {
        super.initToolBar(savedInstanceState);
        setTitle("收益记录");
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        super.initData(savedInstanceState);
        MineApiUtils.getEarningsList(subModelList -> {
            List<WithDrawInfoListBean> dataList = JSON.parseArray(subModelList.getItems(), WithDrawInfoListBean.class);
            if (dataList != null && dataList.size() > 0) {
                listAdapter = new MineWithDrawInfoListAdapter(this, dataList);
                mBinding.list.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
                mBinding.list.setAdapter(listAdapter);
            }
        }, throwable -> {

        });

    }

    @Override
    protected void initEvent() {

    }

    @Override
    protected MineWithDrawInfoPresenter getPresenter() {
        return new MineWithDrawInfoPresenter(this);
    }
}
